package actions;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import javax.naming.NamingException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import db.DbException;
import db.DbConnectionPool;

public class reviewCheck extends Action{
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws DbException {
			int count = 0;
		try{
			Connection conn = DbConnectionPool.getConnection();
			Statement stmt = conn.createStatement();
			HttpSession session = request.getSession();
			String appId = session.getAttribute("appId").toString();
			ResultSet rs = stmt.executeQuery("SELECT id FROM list_application WHERE app_id='"+appId+"'");
			rs.next();
			if(rs != null)
				while(rs.next())
					count++;
			conn.commit();
			conn.close();
		}catch (SQLException ex) {
			throw new DbException(ex);
		} catch (NamingException ex) {
			throw new DbException(ex);
		}
		//if(count < 3)
		//	return mapping.findForward("failure");
		//else
			return mapping.findForward("success");
		
	
	}
}
